<template>
	<view class="page">
		<c-navBar title="个人中心" isTran isBack color="#FFFFFF"></c-navBar>
		<div class="head">
			<image class="head_bg" src="/static/tabbar/mine_bg.png" mode="" />
			<nav-bar title="个人中心" />
			<view class="head_info">
				<image class="header" :src="userInfo.avatar?vuex_imgUrl+userInfo.avatar:'/static/common/header-img.png'"
					mode="" @click="$fn.jumpPage('/pages/my/pages/information')" />
				<view class="name">{{userInfo.nickname||'用户名'}}</view>
				<view class="phone">{{$fn.phoneEn(userInfo.phone)}}</view>
			</view>
		</div>
		<view class="main">
			<view class="list">
				<view class="list_item" v-for="v in list" :key="v.icon" @click="goPage(v.url)">
					<view class="item_l">
						<image class="list_icon" :src="v.icon" mode="" />
						<view class="list_title">{{v.title}}</view>
					</view>
					<view class="item_r">
						<view v-if="v.title=='会员中心'&&userInfo.vipExpireTime" class="date">
							到期时间：{{$fn.parseTime(userInfo.vipExpireTime,'{y}-{m}-{d}')}}</view>
						<u-icon name="arrow-right" color="#999" size="28rpx" />
					</view>
				</view>
			</view>
		</view>
		<liu-drag-button @clickBtn="clickBtn">
			<image class="share_icon" src="/static/tabbar/share_icon.png" mode=""></image>
		</liu-drag-button>
		<c-share ref="share" />
	</view>
</template>

<script>
	export default {
		data() {
			return {
				userInfo: {
					id: '',
					avatar: "",
					nickname: "用户名",
					phone: '',
					vipExpireTime: ''
				},
				list: [{
					title: '个人信息',
					icon: '/static/tabbar/mine-op1.png',
					url: '/pages/my/pages/information'
				}, {
					title: '会员中心',
					icon: '/static/tabbar/mine-op2.png',
					url: '/pages/my/pages/memberCenter'
				}, {
					title: '推广中心',
					icon: '/static/tabbar/mine-op3.png',
					url: '/pages/my/pages/promotionCenter'
				}, {
					title: '我的收藏',
					icon: '/static/tabbar/mine-op4.png',
					url: '/pages/my/pages/myCollection'
				}, {
					title: '使用协议',
					icon: '/static/tabbar/mine-op5.png',
					url: '/pages/my/pages/settings'
				}]
			}
		},
		onShow() {
			this.getUserInfoFn()
		},
		methods: {
			getUserInfoFn() {
				this.$api.getUserInfo().then(res => {
					this.userInfo = res.data
					console.log('用户信息', res);
				})
			},

			clickBtn() {
				console.log('去分享');
				this.$refs.share.getSharePosterFn()
			},
			// 跳转页面
			goPage(url) {
				uni.navigateTo({
					url
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.head {
		width: 750rpx;
		height: 720rpx;
		overflow: hidden;

		.head_bg {
			width: 750rpx;
			height: 720rpx;
			position: absolute;
			top: 0;
			z-index: -1;
		}

		.head_info {
			display: flex;
			flex-direction: column;
			align-items: center;
			margin-top: 240rpx;

			.header {
				width: 240rpx;
				height: 240rpx;
				border-radius: 50%;
			}

			.name {
				font-weight: bold;
				font-size: 48rpx;
				color: #FFFFFF;
				line-height: 47rpx;
				margin: 28rpx 0;
			}

			.phone {
				font-weight: 400;
				font-size: 32rpx;
				color: #FFFFFF;
			}

		}
	}

	.main {
		padding-bottom: 30rpx;

		.list {
			background: #FFFFFF;
			border-radius: 20rpx;
			padding: 0 24rpx;
			box-sizing: border-box;
			margin: -40rpx auto 0;


			.list_item {
				padding: 40rpx 0;
				display: flex;
				align-items: center;
				justify-content: space-between;
				border-bottom: 1rpx solid #E6E6E6;


				.item_l {
					display: flex;
					align-items: center;
					gap: 18rpx;

					.list_icon {
						width: 32rpx;
						height: 32rpx;
					}

					.list_title {
						font-size: 32rpx;
						color: #4D4D4D;
						line-height: 38rpx;
					}

				}

				.item_r {
					display: flex;
					align-items: center;
					gap: 10rpx;

					.date {
						font-weight: 400;
						font-size: 24rpx;
						color: #666666;
					}

				}

			}

		}

	}

	.share_icon {
		width: 80rpx;
		height: 96rpx;
	}
</style>